<?php

namespace App\Http\Controllers\Admin\Wechat\Manager;

use Illuminate\Http\Request;
use App\Http\Controllers\AdminController;
/**
 * 用户标签 暂不用。。。
 */
class UserTagController extends AdminController
{
    /**
     * 获取列表数据
     * @param  Request $request [description]
     * @return [type]           [description]
     */
    function getLists(Request $request ){
        $tags = app('wechat.official_account')->user_tag->list();
    	$this->ajaxJson(0,'',['result'=>$tags,'total'=>count($tags)]);
    }

    /**
     * 标签更新
     * @param  Request $request [description]
     * @return [type]           [description]
     */
    function updateTag(Request $request){
    	$id = $request->input('id');
    	$name = $request->input('name');
    	$tag = app('wechat.official_account')->user_tag;
    	if($id>0){
    		$result = $tag->update($id,$name);
    	}else{
    		$result = $tag->create($name);
    	}
    	if(!$result){
    		$this->ajaxJson(1,'修改失败,请确认公众号权限');
    	}
    	$this->ajaxJson(0,'更新成功');
    }

    function deleteTag($id){
    	app('wechat.official_account')->user_tag->delete($id);
    	$this->ajaxJson(0,'删除成功');
    }
}
